<template>
  <div>
	  
	  删除未完成订单
	  
	  <div class="item" v-for="odd in wait_odd_list" v-bind:class="[odd.in_or_out?'in':'out']" @click="toDelOdd(odd.id)">
	  
	  	<div>{{odd.in_or_out?'入库单':'出库单'}}</div>
	  	<div>订单编号: {{odd.id}}</div>
	  	<div>所属库房: {{odd.warehouse_name}}</div>
	  	<div>来往单位: {{odd.subject_name}}</div>
	  	<div>下单人员: {{odd.sponsor}}</div>
	  	<div>操作人员: {{odd.operator}}</div>
	  	<div>订单生成时间: {{getLocalTime_(odd.create_time)}}</div>
	  	<div>订单完成时间: {{getLocalTime_(odd.end_time)}}</div>
	  	<div class="remark">备注与用途: {{odd.remark}}</div>
	  
	  </div>

  </div>
</template>

<script>
	import {get_odd_by_status} from "../../utils/get_all_odd.js"
	import {
		getLocalTime
	} from "../../utils/date.js"
	import {
		del_odd
		
	} from '../../utils/del_odd.js'
	import {
		Toast,Dialog
		
	} from 'vant'
  export default {
    name: '',
    components: {},
    props: {},
    data() {
      return {
		  wait_odd_list: [],
		  odd_id: null,
	  }
    },
    methods: {
		getLocalTime_(nS) {
			return getLocalTime(nS)
		},
		toDelOdd(odd_id) {
		
			// console.log(odd_id)
			this.odd_id = odd_id
			this.show = true
			
			Dialog.confirm({
			  title: '确认删除',
			  message: '确认删除：ID为 ' + this.odd_id + ' 的未完成订单吗？',
			})
			  .then(() => {
			    // on confirm
				del_odd(
					odd_id,
					()=>{
						Toast('删除成功')
					}
					
				)
				
				this.get_odd_by_status_()
			  })
			  .catch(() => {
			    // on cancel
				Toast('取消')
			  });
		},
		
		get_odd_by_status_(){
			get_odd_by_status(
				'wait', '1',
				res=>{
					console.log(res)
					this.wait_odd_list = res
				}
			)
			
		},
	},
    computed: {},
    watch: {},
    created() {},
    mounted() {
		
		this.get_odd_by_status_()
		
    },
  }
</script>

<style scoped lang="less">
	.item {
		background-color: #F0F0F0;
		margin: 5px;
	
		div {
			display: inline-block;
			margin: 5px;
		}
	
		.remark {
			display: block;
			color: blue;
		}
	}

</style>
